

# 925. 长按键入

def isLongPressedName(name, typed):
    """
    :type name: str
    :type typed: str
    :rtype: bool
    """
    if name[0] != typed[0]:
        return False
    i = 0
    j = 0
    while True:
        if j == len(typed) and i != len(name):
            return False
        elif i == len(name):
            if j == len(typed):
                return True
            else:
                for s in range(j, len(typed)):
                    if typed[s] != typed[j - 1]:
                        return False
                return True
        if name[i] == typed[j]:
            i = i + 1
            j = j + 1
        else:
            if j != len(typed):
                if typed[j] == typed[j - 1]:
                    j = j + 1
                else:
                    return False
    return True

if __name__ == "__main__":
    name = "alex"
    typed = "aaleex"
    isLongPressedName(name,typed)